//
//  JLTableViewCell.m
//  JL网易彩票progress
//arrowAccessoryView
//  Created by sunjinliang on 15/11/10.
//  Copyright © 2015年 sunjinliang. All rights reserved.
//

#import "JLTableViewCell.h"
#import "JLSettingitem.h"
#import "JLSettingLabelitem.h"
#import "JLSettingArrowitem.h"
#import "JLSettingSwitchitem.h"
@interface JLTableViewCell()
@property(nonatomic,strong)UIImageView * arrowAccessoryView;
@property(nonatomic,strong)UISwitch * switchAccessoryView;
@property(nonatomic,strong)UILabel * labelAccessoryView;
@end
@implementation JLTableViewCell

- (void)awakeFromNib {
    // Initialization code
}
-(UIImageView *)arrowAccessoryView{
    
    if (_arrowAccessoryView==nil) {
        _arrowAccessoryView=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"arrow_right"]];
    }
    
    return _arrowAccessoryView;
    
}
-(UISwitch *)switchAccessoryView{
    if (_switchAccessoryView==nil) {
        _switchAccessoryView=[[UISwitch alloc]init];
    }
    return _switchAccessoryView;
}
-(UILabel *)labelAccessoryView{
    if (_labelAccessoryView==nil) {
        _labelAccessoryView=[[UILabel alloc]init];
    }
    return _labelAccessoryView;
}
+(instancetype)cellWithTableView:(UITableView *)tableView{
    static NSString * ID=@"cell";
    JLTableViewCell * cell=[tableView dequeueReusableCellWithIdentifier:ID];
    if (cell==nil) {
        cell=[[JLTableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:ID];
        
    }
    return cell;
}
-(void)setItem:(JLSettingitem *)item{
    _item=item;
  
    self.imageView.image=item.icon;
    self.textLabel.text=item.title;
    self.detailTextLabel.text=item.subTitle;
    [self setUpRightView];
    

}
-(void)setUpRightView{
    if ([self.item isKindOfClass: [JLSettingArrowitem class]]) {
        self.accessoryView=self.arrowAccessoryView;
    }else if ([self.item isKindOfClass: [JLSettingSwitchitem class]]){
        self.accessoryView=self.switchAccessoryView;
        JLSettingSwitchitem *sw=(JLSettingSwitchitem*)self.item;
        self.switchAccessoryView.on=sw.open;
        self.accessoryView=self.switchAccessoryView;
        
    }else if ([self.item isKindOfClass:[JLSettingLabelitem class]]){
        self.accessoryView=self.labelAccessoryView;
    }else{
        self.accessoryView=nil;
    }
    
}
@end
